//
//  ILiveRenderView+LBHelper.m
//  AFNetworking
//
//  Created by 刘文扬 on 2018/3/20.
//

#import "ILiveRenderView+LBHelper.h"
#import <objc/runtime.h>
#import <Masonry.h>

static void *memeberModelKey = &memeberModelKey;
static void *isOwnSideKey = &isOwnSideKey;

static void *videoIndexKey = &videoIndexKey;

static void *labelKey = &labelKey;

@interface ILiveRenderView()

/** label*/
@property(nonatomic,strong)UILabel *lb_nameLabel;

@end

@implementation ILiveRenderView (LBHelper)

-(LBAVMemberModel *)memberModel
{
    return objc_getAssociatedObject(self, &memeberModelKey);
}

-(void)setMemberModel:(LBAVMemberModel *)memberModel
{
    objc_setAssociatedObject(self, &memeberModelKey, memberModel, OBJC_ASSOCIATION_RETAIN);
}

-(UILabel *)lb_nameLabel
{
    
    return objc_getAssociatedObject(self, &labelKey);
    
}

-(void)setLb_nameLabel:(UILabel *)lb_nameLabel
{
    objc_setAssociatedObject(self, &labelKey, lb_nameLabel, OBJC_ASSOCIATION_RETAIN);
}

-(NSNumber *)isOwnSide
{
    return objc_getAssociatedObject(self, &isOwnSideKey);
}

-(void)setIsOwnSide:(NSNumber *)isOwnSide
{
    objc_setAssociatedObject(self, &isOwnSideKey, isOwnSide, OBJC_ASSOCIATION_RETAIN);
}


-(NSNumber *)videoIndex
{
    return objc_getAssociatedObject(self, &videoIndexKey);
}

-(void)setVideoIndex:(NSNumber *)videoIndex
{
    objc_setAssociatedObject(self, &videoIndexKey, videoIndex, OBJC_ASSOCIATION_RETAIN);
}


-(void)addNameLabel
{
    if (!self.lb_nameLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor redColor];
        label.numberOfLines = 1;
        self.lb_nameLabel = label;
        
        [self addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.trailing.offset(0);
        }];
    }
}

-(void)updateNameWithString:(NSString *)string
{
    self.lb_nameLabel.text = string;
}


@end

